<template>
  <div class="page">
    <div class="top">
      <div class="col">
        <div class="label">已连续签到</div>
        <div class="num">
          <div class="num-item">0</div>
          <div class="num-item">0</div>
          <div class="text">天</div>
        </div>
        <div class="text">累计签到3天</div>
      </div>
      <div class="integer">
        <div class="count"><span class="val">{{Integral}}</span><span class="text">积分</span></div>
      </div>
    </div>
    <div class="sign-wrap">
      <div class="rows">
        <div
          class="item"
          v-for="(item, index) in days"
          :key="index"
        >
          <div class="icon">
            <img
              src="/static/img/linpin.png"
              alt=""
            >
          </div>
          <div class="label">{{item}}天</div>
        </div>
      </div>
      <div
        class="btn"
        @click="sign()"
      >立即签到</div>
    </div>
    <div class="advert">
      <img
        src="/static/img/jifen_bg.png"
        alt=""
      >
    </div>
  </div>
</template>
<style lang="scss" scoped>
img {
  width: 100%;
  height: 100%;
}
.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100%;
  background: #f5f5f5;
  color: #fff;
  font-size: 0.3rem;
  .main {
    margin: 0.3rem;
  }
}
.advert {
  margin: 0.3rem;
  border-radius: 0.3rem;
  overflow: hidden;
  height: 2.5rem;
  img {
    width: 100%;
    height: 100%;
  }
}
.top {
  background: #54bf7b;
  height: 3rem;
  padding: 0.3rem;
  padding-bottom: 1rem;
  border-radius: 0 0 0.4rem 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .col {
    display: flex;
    flex-flow: column;
    .label {
      margin-bottom: 0.3rem;
      font-size: 0.4rem;
    }
    .num {
      display: flex;
      .num-item {
        padding: 0.1rem 0.25rem;
        background: #fff;
        color: #54bf7b;
        font-size: 0.5rem;
        margin-right: 0.2rem;
        border-radius: 0.1rem;
        align-items: center;
      }
      .text {
        font-size: 0.4rem;
      }
    }
    .text {
      margin: 0.2rem 0;
      font-size: 0.3rem;
      color: #fff;
    }
  }
  .count {
    display: flex;
    align-items: center;
    .val {
      font-size: 0.5rem;
      margin-right: 0.1rem;
    }
    .text {
      margin-top: 0.2rem;
    }
  }
  h1 {
    font-weight: bold;
    padding: 0.3rem 0;
    font-size: 0.4rem;
  }
}
.sign-wrap {
  display: flex;
  background: #fff;
  margin: 0.3rem;
  border-radius: 0.3rem;
  margin-top: -1rem;
  flex-flow: column;
  padding-bottom: 0.4rem;
  .rows {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem;
    .item {
      display: flex;
      flex-flow: column;
      justify-content: center;
      align-items: center;
      .icon {
        width: 0.65rem;
        height: 0.65rem;
        margin-bottom: 0.1rem;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .label {
        color: #333;
        font-size: 0.2rem;
      }
    }
  }
  .btn {
    margin: 0 auto;
    background: linear-gradient(to bottom, #54bf7b, #7ce2a1);
    border-radius: 0.3rem;
    color: #fff;
    font-size: 0.3rem;
    padding: 0.1rem 0.25rem;
  }
}
</style>
<script>
import { mapState } from 'vuex'
export default {
  data () {
    return {
      days: 7
    }
  },
  onLoad () {
  },
  computed: {
    ...mapState(['Integral', 'Excount'])
  },
  methods: {
    sign() {
      this.$get('api/signin/userSignin').then(res => {
        if (res.data.success) {
          this.updateMoney()
          this.$toast(res.data.msg)
        }
      })
    },
    updateMoney() {
      this.$store.dispatch('updateIntegral')
      this.$store.dispatch('updateExcount')
    }
  }
}
</script>